package com.project.market.service.impl;

import com.project.market.db.domain.MarketAddressExample;
import com.project.market.db.domain.MarketAdmin;
import com.project.market.db.domain.MarketAdminExample;
import com.project.market.db.domain.MarketUser;
import com.project.market.db.mapper.MarketAdminMapper;
import com.project.market.service.AdminAuthService;
import com.project.market.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

public class AdminAuthServiceImpl implements AdminAuthService {
    @Override
    public MarketAdmin login(String username, String password) {

        SqlSession session = MybatisUtil.getSession();
        MarketAdminMapper mapper = session.getMapper(MarketAdminMapper.class);

        // Example类主要用来构建查询条件
        MarketAdminExample marketAdminExample = new MarketAdminExample();
        // 创建条件语句、构建具体的条件
        MarketAdminExample.Criteria criteria = marketAdminExample.createCriteria();
        criteria.andUsernameEqualTo(username).andPasswordEqualTo(password);
        MarketAdmin marketAdmin = mapper.selectOneByExample(marketAdminExample);
        session.commit();
        session.close();
        return marketAdmin;
    }
}
